﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Windows.Media.Imaging;

namespace PlayDeezGames.Common
{
    public class ImageBrushes
    {
        private Dictionary<string, string> lookUpTable = new Dictionary<string, string>();
        public Dictionary<string, string> LookUpTable
        {
            get
            {
                return lookUpTable;
            }
        }
        private Dictionary<string, ImageBrush> imageBrushes = new Dictionary<string, ImageBrush>();
        public ImageBrush this[string key]
        {
            get
            {
                if (imageBrushes.ContainsKey(key))
                {
                    return imageBrushes[key];
                }
                else
                {
                    if (lookUpTable.ContainsKey(key))
                    {
                        BitmapImage bitmap = new BitmapImage(new Uri(lookUpTable[key], UriKind.RelativeOrAbsolute));
                        ImageBrush brush = new ImageBrush();
                        brush.ImageSource = bitmap;
                        imageBrushes.Add(key, brush);
                        return brush;
                    }
                    else
                    {
                        return null;
                    }
                }
            }
            set
            {
                if (imageBrushes.ContainsKey(key))
                {
                    imageBrushes[key] = value;
                }
                else
                {
                    imageBrushes.Add(key, value);
                }
            }
        }
    }
}
